/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufrn.dimap.projetodetalhadodesoftware.chatrmi.controller.treater;

import br.ufrn.dimap.projetodetalhadodesoftware.chatrmi.model.actor.ClientModel;
import br.ufrn.dimap.projetodetalhadodesoftware.chatrmi.controller.exception.CodeNotExistsException;
import br.ufrn.dimap.projetodetalhadodesoftware.chatrmi.controller.exception.TreaterNuloExeption;
import br.ufrn.dimap.projetodetalhadodesoftware.chatrmi.controller.ClientControler;
import br.ufrn.dimap.projetodetalhadodesoftware.chatrmi.model.util.Message;

/**
 *
 * @author jorge
 */
public class ManagerNotification extends TreaterNotification {
    
    public static ManagerNotification managerNotification;

    private ManagerNotification() {
    }
    
    
    public static ManagerNotification getInstance(){
        if(managerNotification == null){
            synchronized(ManagerNotification.class){
                if(managerNotification == null){
                    managerNotification = new ManagerNotification();
                    managerNotification.addNext(new TreaterAddChat());
                    managerNotification.addNext(new TreaterMessage());
                    managerNotification.addNext(new TreaterRemoveChat());
                    managerNotification.addNext(new TreaterUpdateNumclients());

                }
            }
        }
        return managerNotification;
    }
    

    @Override
    public void treatNotification(ClientControler client, Message message) throws CodeNotExistsException, TreaterNuloExeption {
        if(next != null){
            next.treatNotification(client, message);
        }else{
            throw new TreaterNuloExeption();
        }
    }
    
}
